package leetcode.L500;

public class EX494 {
    int target;
    int sum=0;
    int res = 0;
    public int findTargetSumWays(int[] nums, int target) {
        this.target = target;
        dfs(nums,0);
        return res;

    }
    public void dfs(int[] nums,int i){
        if(nums.length<=i){
            if(sum==target){
                res++;
            }
            return;
        }
        sum+=nums[i];
        dfs(nums,i+1);
        sum-=nums[i];
        sum-=nums[i];
        dfs(nums,i+1);
        sum+=nums[i];

    }

    public static void main(String[] args) {
        int[] nums = {1,1,1,1,1};
        EX494 ex494 = new EX494();
        ex494.findTargetSumWays(nums,3);
    }
}
